<!DOCTYPE html>
<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="UTF-8">
    <meta name="referrer" content="no-referrer">
    <title>Book Manage System</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
    <style>
        nav {
            font-size: 1.5rem;
            background-color: #21D4FD;
            background-image: -webkit-linear-gradient(19deg, #21D4FD 0%, #B721FF 100%);
            background-image: -moz-linear-gradient(19deg, #21D4FD 0%, #B721FF 100%);
            background-image: -o-linear-gradient(19deg, #21D4FD 0%, #B721FF 100%);
            background-image: linear-gradient(19deg, #21D4FD 0%, #B721FF 100%);
        }

        h1 {
            font-size: 2rem;
            color: white;
        }

        li {
            margin: 10px 20px;
        }

        th {
            width: 100px;
        }

        label {
            margin: auto;
            padding-right: 20px;
        }

        .input-group {
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
<nav class="navbar navbar-expand-sm bg-primary navbar-dark">
    <ul class="navbar-nav">
        <li>
            <h1><a th:href="@{/}" style="color: white; text-decoration: none">Book Manage System</a></h1>
        </li>
        <li class="nav-item">
            <a class="nav-link active" th:href="@{/admin/book/getAll}">Book Manage</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" th:href="@{/admin/reader/getAll}">Reader Manage</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" th:href="@{/admin/record/getAll}">Borrow Manage</a>
        </li>
        <li class="nav-item">
            <a class="nav-link " th:href="@{/admin/system/getAll}">parameter settings</a>
        </li>
    </ul>
    <div class="text-white" style="font-size: medium; position: absolute; bottom: 30px; right: 40px">
        <div class="dropdown">
            <a class="dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true"
               aria-expanded="false"
               th:text="${session.name}+', Hello'">
            </a>
            <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                <a class="dropdown-item" th:href="@{/user/toInfoPage}" sec:authorize="hasRole('USER')">Personal
                    Information</a>
                <a class="dropdown-item" th:href="@{/toChPwdPage}">Modify Password</a>
                <a class="dropdown-item" th:href="@{/logout}">Logout</a>
            </div>
        </div>
    </div>
</nav>


<div class="container">

    <form th:action="@{/admin/book/add}" method="post">
        <div class="input-group">
            <label for="bookName">bookName</label>
            <input type="text" class="form-control" id="bookName" name="bookName" th:value="${book.getBookName()}">
        </div>
        <div class="input-group">
            <label for="author">author</label>
            <input type="text" class="form-control" id="author" name="author" th:value="${book.getAuthor()}">
        </div>
        <div class="input-group">
            <label for="publisher">publisher</label>
            <input type="text" class="form-control" id="publisher" name="publisher" th:value="${book.getPublisher()}">
        </div>
        <div class="input-group">
            <label for="isbn">ISBN</label>
            <input type="text" class="form-control" id="isbn" name="isbn" th:value="${book.getIsbn()}">
        </div>
        <div class="input-group">
            <label for="description">description</label>
            <textarea type="text" class="form-control" id="description"
                      name="description">[[${book.getDescription()}]]</textarea>
        </div>
        <div class="input-group">
            <label for="category">category</label>
            <!--                    <input type="text" class="form-control" id="classId" name="classId">-->
            <select class="custom-select" id="category" name="category">
                <option selected>Choose...</option>

            </select>
        </div>
        <div class="input-group">
            <label for="price">price</label>
            <input type="text" class="form-control" id="price" name="price" th:value="${book.getPrice()}">
        </div>
        <div class="input-group">
            <label for="publishTime">publishTime</label>
            <input type="text" class="form-control" id="publishTime" name="publishTime"
                   th:value="${book.getPublishTime()}">
        </div>
        <div class="input-group" hidden>
            <label for="picture">picture</label>
            <input type="text" class="form-control" id="picture" name="picture" th:value="${book.getPicture()}">
        </div>
        <div class="row">
            <div class="col">
                <div class="input-group">
                    <label for="face">face</label>
                    <!--                    <input type="text" class="form-control" id="classId" name="classId">-->
                    <select class="custom-select" id="face" name="face">
                        <option selected>Choose...</option>

                    </select>
                </div>
            </div>

            <div class="col">
                <div class="input-group">
                    <label for="column">column</label>
                    <!--            <input type="text" class="form-control" id="pressmark" name="pressmark">-->
                    <select class="custom-select" id="column" name="column">
                        <option selected>Choose...</option>

                    </select>
                </div>
            </div>

            <div class="col">
                <div class="input-group">
                    <label for="row">row</label>
                    <!--                    <input type="text" class="form-control" id="state" name="state">-->
                    <select class="custom-select" id="row" name="row">
                        <option selected>Choose...</option>

                    </select>
                </div>
            </div>


            <div class="col">
                <div class="input-group">
                    <label for="floor">floor</label>
                    <!--                    <input type="text" class="form-control" id="state" name="state">-->
                    <select class="custom-select" id="floor" name="floor">
                        <option selected>Choose...</option>

                    </select>
                </div>
            </div>
        </div>

        <div class="input-group">
            <label for="state">state</label>
            <input type="text" class="form-control" id="state" name="state">
        </div>

        <div class="input-group">
            <label for="number">number</label>
            <input type="text" class="form-control" id="number" name="number">
        </div>

        <input type="submit" value="Submit" class="btn btn-outline-primary btn-lg">
        <a th:href="@{/admin/book/getAll}" class="btn btn-outline-secondary btn-lg" style="margin-left: 40px">Cancle</a>
    </form>
</div>


<script th:inline="javascript">
    function addOp(id, num) {
        let obj = document.getElementById(id);
        for (let i = 1; i <= num; i++) {
            obj.options.add(new
                Option('' + i, i)
            )
            ;
        }
    }

    function addCa(num) {
        let obj = document.getElementById("category");
        for (let i = 0; i < num.length; i++) {
            obj.options.add(new
                Option('' + num[i], num[i])
            )
            ;
        }
    }

    window.onload = function () {
        let face = [[${face}]];
        let column = [[${column}]];
        let row = [[${row}]];
        let floor = [[${floor}]];
        let categories = [[${categories}]];

        addOp("face", face);
        addOp("column", column);
        addOp("row", row);
        addOp("floor", floor);
        addCa(categories);
    }
</script>
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
</body>
</html>
